home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 4083 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.3 KB  |  59 lines

  1. Path: news.pi.net!news
  2. From: heggie <heggie@pi.net>
  3. Newsgroups: comp.lang.c++
  4. Subject: SORTing problem c++
  5. Date: Sat, 27 Jan 1996 21:46:56 -0800
  6. Organization: heggie
  7. Message-ID: <310B0DD0.34F1@pi.net>
  8. NNTP-Posting-Host: gro40.pi.net
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 2.0b5 (Win16; I)
  13.  
  14. I'm used to normal c
  15. just recent i switched to c++, now i am stucked
  16. with a program that did work in c but doesn't
  17. in c++.
  18. it is a program that sorts the 'argv'command line
  19. arguments array,
  20.  
  21. what can I DO???
  22. p.s. I am using borlands c++
  23. p.s. thanks for reading this 
  24.  
  25. #include <stdio.h>
  26. #include <stdlib.h>
  27. #include <string.h>
  28.  
  29.  
  30. int sort_function(char **a, char **b)
  31. {
  32.    return( strcmp(*a, *b));
  33. }
  34.  
  35.  
  36. int main(int argc, char **argv)
  37. {
  38.    int
  39.            x;
  40.  
  41.    qsort(argv, argc, sizeof(char*), sort_function);
  42.  
  43.    for (x = 0; x < argc; x++)
  44.          printf("%s\n", argv[x]);
  45.    return 0;
  46. }
  47.  
  48. ******************************************
  49. these are the error mesages,
  50.  
  51.  
  52. Error ..\SOURCES\OPDR_45.CPP 17: Cannot convert 'int (*)(char * *,char * 
  53. *)' to 'int (*)(const void *,const void *)'
  54. Error ..\SOURCES\OPDR_45.CPP 17: Type mismatch in parameter '__fcmp' in 
  55. call to 'qsort(void *,unsigned int,unsigned int,int (*)(const void 
  56. *,const void *))'
  57.  
  58. >
  59.